<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml11/DTD/xhtml1-transitional.dtd">

<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<%
	/**
	 * @author : Kihoon Lee
	 * @see : VMS Info view
	 * @since : 2009.03.04
	 */
%>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>VMS Info</title>
<s:head theme="ajax"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="inc/css/dhtmlxcalendar.css" rel="stylesheet" type="text/css">

<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/dhtmlXCommon.js"></script>
<script type="text/javascript" src="js/dhtmlxcalendar.js"></script>
<script language="JavaScript">
/////////////////////달력////////////////////////////////////////////////
	function doOnLoad()
	{
		// 달력
		cal1 = new dhtmlxCalendarObject('s_date', false, {isYearEditable: true});
		cal1.setYearsRange(2000, 2050);
		cal1.setPosition(20,-82);
		cal1.draw();
		cal1.setOnClickHandler(selectDate1);

		cal2 = new dhtmlxCalendarObject('e_date', false, {isYearEditable: true});
		cal2.setYearsRange(2000, 2050);
		cal2.setPosition(20,-82);
		cal2.draw();
		// cal2.setOnClickHandler(selectDate2);

		document.getElementById('s_date').onfocus = function() { if (cal2.isVisible()) cal2.hide(); }
		document.getElementById('e_date').onfocus = function() { if (cal1.isVisible()) cal1.hide(); }

		document.body.onclick = function(){calendarHide("cal1,cal2","D");};
	}

	function selectDate1(date)
	{
		document.getElementById('s_date').value = cal1.getFormatedDate(null,date);
		dateFrom = new Date(date);
		dateTo = null;
		cal2.setSensitive(dateFrom, dateTo);
		cal1.hide();
		return true;
	}

	function selectDate2(date)
	{
		document.getElementById('e_date').value = cal1.getFormatedDate(null,date);
		dateTo = new Date(date);
		dateFrom = null;
		cal1.setSensitive(dateFrom, dateTo);
		cal2.hide();
		return true;
	}
/////////////////////달력////////////////////////////////////////////////

	function isCalendar(str)
	{
		var src = new String(str);
	    var len = src.length;
	    for (var i = 0; i < len; i++)
	    {
	    	if (src.charAt(i) != '/')
	    	{
	        	if ((src.charAt(i) < '0') | (src.charAt(i) > '9'))
	        	{
	        		return false;
	        	}
	        }
	    }

	    return true;
	}

	function isZero(str)
	{
		var src = new String(str);
		if (src.charAt(0) == '0')
			return true;
		return false;
	}

	function checkCalendar()
	{
		var startDate = document.getElementById('s_date').value;
		var endDate = document.getElementById('e_date').value;

		if (!checkField(startDate))
		{
			alert('검색 기간 시작일을 선택하세요.');
			return false;
		}
		if (!checkField(endDate))
		{
			alert('검색 기간 종료일을 선택하세요.');
			return false;
		}
		if (startDate.length != 10)
		{
			alert('검색 기간 시작일의 형식이 잘못되었습니다.\n오늘 일자로 변경합니다.');
			document.getElementById('s_date').value = getTodayDate();
			return false;
		}
		if (endDate.length != 10)
		{
			alert('검색 기간 종료일의 형식이 잘못되었습니다.\n오늘 일자로 변경합니다.');
			document.getElementById('e_date').value = getTodayDate();
			return false;
		}
		if (!isCalendar(startDate))
		{
			alert('검색 기간 시작일의 형식이 잘못되었습니다.\n오늘 일자로 변경합니다.');
			document.getElementById('s_date').value = getTodayDate();
			return false;
		}
		if (!isCalendar(endDate))
		{
			alert('검색 기간 종료일의 형식이 잘못되었습니다.\n오늘 일자로 변경합니다.');
			document.getElementById('e_date').value = getTodayDate();
			return false;
		}
		if (isZero(startDate))
		{
			alert('검색 기간 시작일의 형식이 잘못되었습니다.\n오늘 일자로 변경합니다.');
			document.getElementById('s_date').value = getTodayDate();
			return false;
		}
		if (isZero(endDate))
		{
			alert('검색 기간 종료일의 형식이 잘못되었습니다.\n오늘 일자로 변경합니다.');
			document.getElementById('e_date').value = getTodayDate();
			return false;
		}

		var startDateNum = startDate.substr(0, 4) + startDate.substring(5, 7) + startDate.substring(8, 10);
		var endDateNum = endDate.substring(0, 4) + endDate.substring(5, 7) + endDate.substring(8, 10);
		if (!checkOnlyNumber(startDateNum))
		{
			alert('검색 기간 시작일의 형식이 잘못되었습니다.\n오늘 일자로 변경합니다.');
			document.getElementById('s_date').value = getTodayDate();
			return false;
		}
		if (!checkOnlyNumber(endDateNum))
		{
			alert('검색 기간 종료일의 형식이 잘못되었습니다.\n오늘 일자로 변경합니다.');
			document.getElementById('e_date').value = getTodayDate();
			return false;
		}
		if (startDateNum > endDateNum)
		{
			alert('검색 기간 시작일이 종료일보다 늦습니다.');
			return false;
		}

		var todayNum = strReplaceAll(getTodayDate(), '/', '');
		if (todayNum < startDateNum)
		{
			alert('검색 기간 시작일이 미래시점입니다.');
			return false;
		}

		return true;
	}

	function goSearchList()
	{
		var form = document.selectForm;
		form.deletedPhoneno.value = '';
		form.deletedMailCode.value = '';
		form.currentPage.value = 1;

		if (!checkCalendar())
			return false;

		dojo.event.topic.publish("showList");
	}

	function isDownload(phoneno, mailcode, status)
	{
		if (status == 0) // 신규일때.
		{
			var form = document.selectForm;
			form.downloadPhoneno.value = phoneno;
			form.downloadMailCode.value = mailcode;

			dojo.event.topic.publish("showList");
		}
	}

	function isDelete(phoneno, mailcode)
	{
		if (confirm('VMS(메일코드:' + mailcode + ')를 \n삭제하시겠습니까?'))
		{
			var form = document.selectForm;
			form.deletedPhoneno.value = phoneno;
			form.deletedMailCode.value = mailcode;

			dojo.event.topic.publish("showList");
		}
	}

	function isPaging(page)
	{
		var form = document.selectForm;
		form.currentPage.value = page;

		dojo.event.topic.publish("showList");
	}
</script>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="doOnLoad();">

<s:form id="selectForm" name="selectForm" theme="simple">
<s:hidden name="deletedPhoneno"		id="deletedPhoneno" />
<s:hidden name="deletedMailCode"	id="deletedMailCode" />
<s:hidden name="currentPage"		id="currentPage" />
<s:hidden name="downloadPhoneno"	id="downloadPhoneno" />
<s:hidden name="downloadMailCode"	id="downloadMailCode" />

<table width="691" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="14">
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="327"><img src="images/t_vms.gif" height="22"></td>
          <td width="140"></td>
          <td align="right" valign="bottom" class="t01">
            <a href="#"><img src="images/icon_home.gif" width="12" border="0" align="absmiddle"></a> &gt; VMS 관리
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td></td>
  </tr>
  <tr>
    <td>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><img src="images/tc01.jpg" width="691" height="25"></td>
        </tr>
        <tr>
          <td background="images/tc02.gif">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td>
                  <table width="655" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td><img src="images/gray01.gif" width="655" height="20"></td>
                    </tr>
                    <tr>
                      <td background="images/gray03.gif">
                        <table width="615" border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr>
                            <td colspan="3">
                              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td width="73">미디어 타입</td>
                                  <td width="118">
                                   
                                  </td>
                                  <td width="40">상태</td>
                                  <td width="384">
                                   
                                  </td>
                                </tr>
                              </table>
                            </td>
                          </tr>
                          <tr>
                            <td height="6" colspan="3"></td>
                          </tr>
                          <tr>
                            <td width="73">검색기간</td>
                            <td width="350">
                            <!-- /////////////////////달력//////////////////////////////////////////////// -->
                              <input type="text" size="12" maxlength="10" name="s_date" id="s_date" style="height:20;background-image:url('images/calendar/calendar.gif');background-repeat:no-repeat;background-position:right 2px;cursor:hand">
                               ~
                              <input type="text" size="12" maxlength="10" name="e_date" id="e_date" style="height:20;background-image:url('images/calendar/calendar.gif');background-repeat:no-repeat;background-position:right 2px;cursor:hand">
                            <!-- /////////////////////달력//////////////////////////////////////////////// -->
                            </td>
                            <td width="192" align="right">
                              <img src="images/bt_inquiry.jpg" width="67" height="25" style="cursor:hand;" onclick="javascript:goSearchList();">
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                    <tr>
                      <td><img src="images/gray02.gif" width="655" height="20"></td>
                    </tr>
                  </table>
                </td>
              </tr>
			  <tr>
                <td height="15">&nbsp;</td>
              </tr>
              <tr>
                <td>
                </td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td><img src="images/tc03.jpg" width="691" height="25"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</s:form>
</body>
</html>
